#pragma once
/*!
 * \file 
 * WndDisplay.h
 */

#define OSD_DATA_FLAG_FILE_NAME			(1<<0)
#define OSD_DATA_FLAG_CPU_USAGE			(1<<1)
#define OSD_DATA_FLAG_VIDEO_CODEC		(1<<2)
#define OSD_DATA_FLAG_V_FPS_DEC			(1<<3)
#define OSD_DATA_FLAG_V_FPS_DISP		(1<<4)
#define OSD_DATA_FLAG_V_BIT_RATE		(1<<5)
#define OSD_DATA_FLAG_A_FORMAT			(1<<6)
#define OSD_DATA_FLAG_A_FREQ			(1<<7)
#define OSD_DATA_FLAG_A_BIT_PER_SAMP	(1<<8)
#define OSD_DATA_FLAG_A_BIT_RATE		(1<<9)
#define OSD_DATA_FLAG_START_TIME		(1<<10)
#define OSD_DATA_FLAG_END_TIME			(1<<11)
#define OSD_DATA_FLAG_CURRENT_TIME		(1<<12)

/*!
 * \brief contents of OSD to be shown
 */
typedef struct _OSD_DATA
{
	/*!
	 * dwFlags:
	 *
	 *	OSD_DATA_FLAG_FILE_NAME			shows file name
	 *	OSD_DATA_FLAG_CPU_USAGE			shows CPU usage
	 *	OSD_DATA_FLAG_VIDEO_CODEC		shows video codec type
	 *	OSD_DATA_FLAG_V_FPS_DEC			shows video fps of decoding
	 *	OSD_DATA_FLAG_V_FPS_DISP		shows video fps of displaying
	 *	OSD_DATA_FLAG_V_BIT_RATE		shows video bit rate
	 *	OSD_DATA_FLAG_A_FORMAT			shows audio format
	 *	OSD_DATA_FLAG_A_FREQ			shows audio frequency
	 *	OSD_DATA_FLAG_A_BIT_PER_SAMP	shows audio bit per sample
	 *	OSD_DATA_FLAG_A_BIT_RATE		shows audio bit rate
	 *	OSD_DATA_FLAG_START_TIME		shows video start time of the current file
	 *	OSD_DATA_FLAG_END_TIME			shows video end time of the current file
	 *	OSD_DATA_FLAG_CURRENT_TIME		shows time of current frame
	 * 
	 */
	DWORD dwFlags;			
	CString strFileName;
	CString strCPUusage;
	CString strVideoCodec;
	CString strVideoDecodeFPS;
	CString strVideoDisplayFPS;
	CString strVideoBitRate;
	CString strAudioFormat;
	CString strAudioFrequency;
	CString strAudioBitPerSec;
	CString strBitRate;
	CString strStartTime;
	CString strEndTime;
	CString strPlayTime;
} ST_OSD_DATA, *LPST_OSD_DATA;

// CWndDisplay
/*!
 * \brief Displaying video data to the screen.
 *
 * class for display video data to the screen
 *
 * - header file: WndDisplay.h
 * - lib: display.lib
 * - DLL: display.dll
 */
class AFX_EXT_CLASS CWndDisplay : public CWnd
{
	DECLARE_DYNAMIC(CWndDisplay)

public:
	/*!
	 * Display creation type
	 */
	enum _DISPLAY_TYPE
	{
		DISPLAY_TYPE_DIRECTDRAW,	/**< DirectDraw type */
		DISPLAY_TYPE_DIRECTD3D9		/**< DirectD3D9 type */
	};
public:
	/*!
	 * Create display Object
	 * @return Display Object. If NULL, the display object cannot be used.
	 *
	 * @param nType nType is a value defined in enumerator _DISPLAY_TYPE
	 *
	 *	if nType = DISPLAY_TYPE_DIRECTDRAW, a display object is created with DirectDraw
	 *	if nType = DISPLAY_TYPE_DIRECTD3D9, a display object is created with DirectD3D
	 *
	 * @param pParent Handle to the application window for display.
	 * 
	 * @see _DISPLAY_TYPE
	 */
	static CWndDisplay *CreateDisplay(int nType, CWnd *pParent);
	CWndDisplay();
	virtual ~CWndDisplay();	/**< Destructor 	*/

protected:
	DECLARE_MESSAGE_MAP()

public:
	/*!
	 * Initialize display screen
	 * @param pCallbackWnd Pointer to the window which is a target to be sent or posted.
	 * @param dwWidth width of target screen
	 * @param dwHeight height of target screen
	 * @param hLogo Bitmap handle of Logo image which shows no video images
	 *
	 * @return returns TRUE if successfully created. FALSE otherwise.
	 */
	virtual BOOL CreateScreen(CWnd* pCallbackWnd, DWORD dwWidth, DWORD dwHeight, HBITMAP hLogo) { return FALSE; };
	virtual void InitLayout(LAYOUT layout) {};
	virtual void InitDisScreen(LAYOUT layout, int nSection=0) {};
	virtual void UpdateScreen(BOOL bShowLogo) {};
	virtual void SetLayout(LAYOUT nLayout, int nSection) {};
	virtual void SetMaxLayout(LAYOUT nLayout) {};

	/*!
	 * Render the screen again
	 *
	 * @param bShowLogo if TRUE, this function updates screen with logo image. 
	 * Otherwise, updates the previous screen again.
	 */
	virtual void UpdateScreen2(BOOL bShowLogo) {};

	/*!
	 * Release display resource and create display screen again.
	 * Usually it is called when width and height of image are changed.
	 *
	 * @param nCh must be set to 0
	 * @param nWidth new value of width
	 * @param nHeight new value of height
	 *
	 * @return returns TRUE if successfully created. FALSE otherwise.
	 */
	virtual BOOL ReCreateScreen(int nCh, int nWidth, int nHeight) { return FALSE; };
	/*!
	 * Render video image
	 *
	 * @param nSection must be set to 0
	 * @param pData Pointer to a video image
	 * @param nWidth width of image
	 * @param nHeight height of image
	 * @param nField if image is interlace video, odd image for 0, even image for 1, progressive image for -1
	 * @param nFormat
	 *
	 *	nFormat = FMT_YUV422PK_UD : YUV422 packed image and upside down
	 *	nFormat = FMT_YUV422PL_UU : YUV422 planar image
	 *	nFormat = FMT_RGB : RGB 32bit image
	 *
	 * @return TRUE if it renders image successfully. FALSE otherwise.
	 *
	 * @see _TAG_VIDEO_FORMAT
	 *
	 */
	virtual BOOL SetVidStream(int nSection, BYTE *pData, int nWidth, int nHeight, int nField, int nFormat = FMT_YUV422PK_UD) { return FALSE; };

	/*!
	 * Supports to turn right to left and upside down
	 *
	 * @param oReverse
	 *
	 *	0 : disable
	 *	1 : right-side left
	 *	2 : upside down
	 *	3 : rotate 180 degree
	 */
	virtual void SetVidReverse(BYTE oReverse) {};

	virtual BYTE* GetPrintData(int nSection) { return NULL; };
	/*!
	 * Converts image data to RGB 32bit data
	 * 
	 * @param nSection must be set to 0
	 * @param pData Pointer to a video image
	 * @param dwWidth width of image
	 * @param dwHeight height of image
	 * @param nFormat
	 *
	 *	nFormat = FMT_YUV422PK_UD : YUV422 packed image and upside down
	 *	nFormat = FMT_YUV422PL_UU : YUV422 planar image
	 *	nFormat = FMT_RGB : RGB 32bit image
	 *
	 * @see _TAG_VIDEO_FORMAT
	 *
	 */
	virtual BYTE* GetPrintData(int nSection, BYTE *pData, DWORD dwWidth, DWORD dwHeight, int nFormat) { return NULL; };

	/*!
	 * All most same as UpdateScreen2 function with showing logo
	 */
	virtual void SetPopupScreen() {};

	virtual DWORD GetImageWidth(int nCh) { return 0; };
	virtual DWORD GetImageHeight(int nCh) { return 0; };

	/*!
	 * Release objects and resources associated with display screen
	 */
	virtual void ReleaseAllScreen() {};
	virtual void ReleaseDDraw() {};

	/*!
	 * Set ID for recognizing display screen
	 *
	 * @param nID unique ID
	 */
	virtual void SetDisplayID(int nID) {};

	/*!
	 * Set aspect ratio of image
	 *
	 * @param dwRatio
	 *
	 *	RATIO_KEEP	keep the image's own ratio
	 *	RATIO_ORIGIANL the image's own ratio
	 *	RATIO_DEFAULT the same as RATIO_ORIGINAL
	 *	RATIO_16_TO_09 width:height = 16:9
	 *	RATIO_04_TO_03 width:height = 4:3
	 *
	 * @param bMaximized if FALSE, although display screen is not exactly 16:9, it displays image fixed to the display screen.
	 *
	 * @see _TAG_RATIO
	 */
	virtual void SetAspectRatioMode(DWORD dwRatio, BOOL bMaximized) {};
	/*!
	 * Displays image with original size when the screen is larger than the image.
	 * If the display screen is smaller than the image, it displays the image with scaling down.
	 *
	 * @param bOriginal if TRUE, shows image with original size.
	 */
	virtual void SetSizeOriginal(BOOL bOriginal) {};
	/*!
	 * Decide whether it copies and displays image or not.
	 * It is called when the screen is hide.
	 *
	 * @param bDisplay if TRUE, shows the image.
	 */
	virtual void SetDisplayStatue(BOOL bDisplay) {};
	/*!
	 * Calls this function when this program lost its surface to display. 
	 */
	virtual BOOL ResetDisplay() { return FALSE; };
	/*!
	 * Gets the string of identifying display-type.
	 * @return 
	 *
	 *	"DirectD3D9" : surfaces created with DirectD3D9
	 *	"DirectDraw" : surfaces created with DirectDraw
	 */
	virtual CString GetDisplayIdentifier() { return _T(""); };

	//PIP
	/*!
	 * Decide to show PIP(picture in picture) screen when zoom in is applied.
	 *
	 * @param bShow if TRUE, shows PIP. Otherwise hides it.
	 */
	virtual void ShowPIP(BOOL bShow);

	//Zoom
	virtual int GetZoomInfo() { return ZOOM_DEFAULT; }; /**< Get current zoom value 	*/
	/*!
	 * Set new zoom value with position
	 *
	 * @param nZoom New zoom value ranged from 0x40(ZOOM_MIN) to 0x400(ZOOM_MAX) with 0x10(ZOOM_UNIT) unit.
	 * @param ptZoom The position zoom action occurred. it could be out side of image
	 */
	virtual void SetZoomInfo(int nZoom, CPoint ptZoom) {};
	/*!
	 * When PIP is on and zoom-in occurs, the original image shows in PIP box.
	 * This function decides whether the original image shows or which positions PIP window places
	 *
	 * @param bShowOrg shows or not the original image
	 * @param nPipPos position of PIP window
	 *
	 *	POS_TOP_LEFT : top-left position
	 *	POS_TOP_RIGHT : top-right position
	 *	POS_BOTTOM_LEFT : bottom-left position
	 *	POS_BOTTOM_RIGHT : bottom-right position
	 *
	 * @see _POS
	 */
	virtual void SetDispZoomPIP(BOOL bShowOrg, int nPipPos) {};
	/*!
	 * Allows wheel scroll action with CTRL key or without CTRL key.
	 *
	 * @param bUseCtrl If TRUE, zoom action applies with CTRL key.
	 */
	virtual void SetZoomOption(BOOL bUseCtrl) {};

	/*!
	 * Zoom parameters is allowed to be set by outside of this object.
	 * This function gets the current zoom parameters.
	 */
	virtual void GetDispZoomStatus(int &nZoom, CPoint &ptZoom, CRect &rtZoom, CRect &rtDst) {};
	/*!
	* Zoom parameters is allowed to be set by outside of this object.
	* This function sets the current zoom parameters.
	 */
	virtual void SetDispZoomStatus(int &nZoom, CPoint &ptZoom, CRect &rtZoom, CRect &rtDst) {};

	virtual void SetState(int nState) {};
	virtual int GetState() { return 0; };
	virtual BOOL GetResetState() { return FALSE; };
	virtual void SetResetState(BOOL bReset) {};


	/*!
	 * OSD data to be shown
	 */
	virtual void SetOSDData(LPST_OSD_DATA lpstOSDData) {};
};


